<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" template="/WEB-INF/templates/connected.xhtml">
	<ui:define name="content">
		<h:form id="form">
			<script type="text/javascript">
		$(document).ready(function(){
			submitBtn.disable();
			cancelBtn.disable();
		});
		</script>
			<p:panel id="panel">
				<p:messages id="messages" />
				<p:fieldset legend="Informations personnelles" toggleable="true" toggleSpeed="500" id="infoPerso">
					<h:panelGrid columns="3" cellspacing="5">
						<p:outputLabel value="Pseudo : " for="pseudo" />
						<p:inplace>
							<p:inputText id="pseudo" value="#{profilController.user.pseudo}" label="firtname" onfocus="submitBtn.enable();cancelBtn.enable();" />
						</p:inplace>
						<p:message for="pseudo" />
						<p:outputLabel value="#{bundles.i18n.firstname} : " for="firtname" />
						<p:inplace>
							<p:inputText id="firtname" value="#{profilController.user.firtName}" label="firtname" onfocus="submitBtn.enable();cancelBtn.enable();" />
						</p:inplace>
						<p:message for="firtname" />
						<h:outputLabel value="#{bundles.i18n.lastname} : " for="lastname" />
						<p:inplace>
							<p:inputText id="lastname" value="#{profilController.user.lastName}" label="lastname" onfocus="submitBtn.enable();cancelBtn.enable();" />
						</p:inplace>
						<p:message for="lastname" />
						<p:outputLabel value="Email  : " for="email" />
						<p:inplace>
							<p:inputText id="email" value="#{profilController.user.email}" label="email" onfocus="submitBtn.enable();cancelBtn.enable();" />
						</p:inplace>
						<p:message for="email" />
						<p:commandButton id="valid" widgetVar="submitBtn" value="Enregistrer" action="#{profilController.updateUser}" update="infoPerso"
							oncomplete="submitBtn.disable();cancelBtn.disable();" />
						<p:commandButton id="cancel" widgetVar="cancelBtn" value="Annuler" action="#{profilController.init}" update="infoPerso"
							oncomplete="submitBtn.disable();cancelBtn.disable();" />
					</h:panelGrid>
				</p:fieldset>
				<p:fieldset legend="Mes Prochain Rdv" toggleable="true" toggleSpeed="500">
					<p:dataTable id="listRdv" value="#{profilController.rdvs}" var="rdv" lazy="true" paginator="true" paginatorPosition="bottom" rows="10" rowsPerPageTemplate="5,10,15" >
						<f:facet name="header">  
               			Vos rendez-vous  
            			</f:facet>
						<p:column>
							<p:commandButton icon="ui-icon-search" update=":form:rdvDetail" oncomplete="rdvDialog.show()" title="View Detail">
								<f:setPropertyActionListener value="#{rdv}" target="#{profilController.selectedRdv}" />
							</p:commandButton>
							<h:outputText value="#{rdv.userId.pseudo} ,#{rdv.dateDebut}" style="margin-left:10px" />
						</p:column>		
					</p:dataTable>
					<p:dialog header="Rdv Detail" widgetVar="rdvDialog" modal="true" showEffect="fade">
						<p:outputPanel id="rdvDetail" style="text-align:center;" layout="block">

							<!-- <p:graphicImage value="/images/cars/#{tableBean.selectedCar.manufacturer}.jpg" /> -->

							<h:panelGrid columns="2" cellpadding="5">
								<h:outputLabel for="rdvStart" value="Debut : " />
								<h:outputText id="rdvStart" value="#{profilController.selectedRdv.dateDebut}" />

								<h:outputLabel for="rdvEnd" value="Fin : " />
								<h:outputText id="rdvEnd" value="#{profilController.selectedRdv.dateFin}" />

								<h:outputLabel for="rdvCompany" value="Société : " />
								<h:outputText id="rdvCompany" value="#{profilController.selectedRdv.company.name}" />
							</h:panelGrid>
						</p:outputPanel>
					</p:dialog>
				</p:fieldset>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>